package com.example.demo.controller;

import com.example.demo.common.Field;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("")
public class TestController {

    @RequestMapping(value = "/test")
    public String num(@RequestBody Map<String, Object> map) {
        List<Field> list = new ArrayList<>();
        for (Map.Entry<String, Object> entry : map.entrySet()) {
            Field field = new Field();
            field.setFieldName(entry.getKey());

            Map<String, Object> value = (Map<String, Object>) entry.getValue();
            String v = (String) value.get("type");
            if (v.startsWith("java.")) {
                field.setFieldType(v);
            } else {

            }

            list.add(field);
        }
        return "sus";
    }

    private List<Field> getFields() {

    }

    private Class<?> getClass(String type) {
        Class<?> cls = null;
        try {
            cls = Class.forName(type);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        return cls;
    }
}
